package com.gyf.mybatis;

import com.gyf.mybatis.dao.IUserDao;
import com.gyf.mybatis.io.Resource;
import com.gyf.mybatis.pojo.User;
import com.gyf.mybatis.sqlsession.SqlSession;
import com.gyf.mybatis.sqlsession.SqlSessionBuilder;
import com.gyf.mybatis.sqlsession.SqlSessionFactory;

import java.io.InputStream;
import java.util.Arrays;
import java.util.List;

public class Main {
    public static void main(String[] args) throws Exception {
        InputStream inputStream = Resource.getResourceAsStream("/SqlMapConfig.xml");
        SqlSessionFactory factory = new SqlSessionBuilder().build(inputStream);
        SqlSession sqlSession = factory.openSession();
        // User user = new User();
        // user.setId(1L);
        // user.setName("gyf");
        // User user1 = sqlSession.selectOne("user.selectOne", user);
        IUserDao userDao = sqlSession.getMapper(IUserDao.class);

        List<User> userList = userDao.findAll();

        System.out.println(Arrays.toString(userList.toArray()));
    }
}